package com.nononsenseapps.feeder.db.entity

import androidx.room.*
import com.nononsenseapps.feeder.db.*
import com.nononsenseapps.feeder.db.room.ID_UNSET
import org.joda.time.DateTime
import org.joda.time.DateTimeZone

@Entity(tableName = FEED_SYNC_ITEM.tableName,
        indices = [Index(value = [FEED_SYNC_ITEM.COL_FEEDID])],
        foreignKeys = [ForeignKey(entity = Feed::class,
        parentColumns = [FEED.COL_ID],
        childColumns = [FEED_SYNC_ITEM.COL_FEEDID],
        onDelete = ForeignKey.CASCADE)])
data class FeedSyncItem @Ignore constructor(
    @PrimaryKey(autoGenerate = true)
        @ColumnInfo(name = FEED_SYNC_ITEM.COL_ID) var id: Long = ID_UNSET,
    @ColumnInfo(name = FEED_SYNC_ITEM.COL_SYNC_SUCCESS) var syncSuccess: Boolean = true,
    @ColumnInfo(name = FEED_SYNC_ITEM.COL_FEEDID) var feedId: Long? = null,
    @ColumnInfo(name = FEED_SYNC_ITEM.COL_CREATEDATE, typeAffinity = ColumnInfo.INTEGER) var createDate: DateTime = DateTime.now(DateTimeZone.UTC),
    @ColumnInfo(name = FEED_SYNC_ITEM.COL_FEED_SYNC_TIME_INTERVAL) var syncTimeInterval: Long=0,
    @ColumnInfo(name = FEED_SYNC_ITEM.COL_FEED_SYNC_NEW_ITEM_COUNT) var syncNewItemCount: Int = 0){

        constructor() : this(id = ID_UNSET)
}
